package com.itheima.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Predicate;

/*
Collection接口中的通用方法
add
remove
removeif
clear
contains
isEmpty
size


 */
public class Demo01 {

    public static void main(String[] args) {
        Collection<String> list= new ArrayList<>();

        list.add("坤坤");
        list.add("签签");
        list.add("滔滔");
        list.add("小鹿鹿");
        System.out.println(list);

        boolean flag = list.remove("签签");
        System.out.println(flag);
        System.out.println(list);
        System.out.println(list.remove("小绵羊"));

        //clear
        /*list.clear();
        System.out.println(list);*/
        //contains
        System.out.println(list.contains("坤坤"));
        System.out.println(list.contains("签签"));
        //isEmpty
      /*  System.out.println(list.isEmpty());
        list.clear();
        System.out.println(list.isEmpty());*/

        //size
        //int size = list.size();
        /*System.out.println( list.size());
        list.clear();
        System.out.println( list.size());*/


        System.out.println(list);
        //removeif  根据条件删除  判断  true   false  不删
        list.removeIf(s-> s.length()==2);
        System.out.println(list);
        list.removeIf(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.startsWith("小");
            }
        });
        System.out.println(list);
    }


}
